package com.changzhi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.changzhi.ldyl.model.UserFollow;
import com.changzhi.ldyl.model.UserFollowers;
import org.apache.ibatis.annotations.Select;


public interface UserFollowersMapper extends BaseMapper<UserFollowers> {

    int insertOrUpdate(UserFollowers userFollowers);

    /**
     * 获取关注数量
     *
     * @param userId
     * @return
     */
    @Select("SELECT COUNT(1) FROM yl_user_followers INNER JOIN yl_user ON yl_user_followers.followed_user_id = yl_user.user_id "
            + "WHERE yl_user_followers.user_id = #{userId} and yl_user.`status`=1")
    int getFollowersCount(String userId);

    /**
     * 获取好友数量
     *
     * @param userId
     * @return
     */
    @Select("SELECT COUNT(1) FROM yl_user_followers INNER JOIN yl_user ON yl_user_followers.followed_user_id = yl_user.user_id "
            + "WHERE yl_user_followers.user_id = #{userId} and yl_user.`status`=1 and yl_user_followers.both_status = 2")
    int getFriend(String userId);

}
